package com.rxyb.sms.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rxyb.core.constants.DbConstants;
import com.rxyb.sms.db.dao.ThirdSmsRecordMapper;
import com.rxyb.sms.db.po.ThirdSmsRecord;
import com.rxyb.sms.service.ThirdSmsRecordService;
import com.rxyb.sms.utils.SmsRspData;
import com.rxyb.toolize.date.DateTime;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 短信发送记录 服务实现类
 * </p>
 *
 * @author DUYH
 * @since 2020-06-11
 */
@Slf4j
@Service
public class ThirdSmsRecordServiceImpl extends ServiceImpl<ThirdSmsRecordMapper, ThirdSmsRecord> implements ThirdSmsRecordService {

    @Autowired(required = false)
    private ThirdSmsRecordMapper thirdSmsRecordMapper;

    @Override
    public void saveRecord(SmsRspData smsRspData) {
        ThirdSmsRecord entity = new ThirdSmsRecord();
        BeanUtils.copyProperties(smsRspData, entity);
        entity.setAddTime(DateTime.getDateTime());
        entity.setUpdateTime(DateTime.getDateTime());
        entity.setRowState(DbConstants.ROW_STATE_VALID);
        thirdSmsRecordMapper.insert(entity);
    }
}
